package com.sc.nft.admin.controller;

import com.sc.nft.annotation.SysMemberLogin;
import com.sc.nft.feign.WxMiniPointsRuleClient;
import com.sc.nft.req.pointsrule.PointsRuleReq;
import com.sc.nft.sup.Result;
import com.sc.nft.vo.pointsrule.PointsRuleDetailsVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

@Slf4j
@RequiredArgsConstructor
@RestController
@RequestMapping("/admin/wxMiniMall/pointsRule")
@Api(tags = "小程序积分规则")
public class WxMiniPointsRuleController{

    private final WxMiniPointsRuleClient wxMiniPointsRuleClient;

    /**
     * 小程序积分规则保存
     * @param request
     * @return
     */
    @PostMapping(value = "/save", produces = MediaType.APPLICATION_JSON_VALUE)
    @ApiOperation(value = "保存规则")
    @SysMemberLogin
    public Result savePointsRule(@Valid @RequestBody PointsRuleReq request) {
        return wxMiniPointsRuleClient.savePointsRule(request);

    }


    /**
     * 小程序积分规则详情
     * @return
     */
    @PostMapping(value = "/details", produces = MediaType.APPLICATION_JSON_VALUE)
    @ApiOperation(value = "小程序积分规则详情")
    @SysMemberLogin
    public Result<PointsRuleDetailsVO> pointsRuleDetails() {
        return Result.success(wxMiniPointsRuleClient.pointsRuleDetails());
    }





}